Adopt adaptive-triangulation 0.3.1: batched tell_pending, Rust default_loss, and a Rust-backend CI job#499
Merged
Merged
Conversation
…t_loss, CI job adaptive-triangulation 0.3.1 fixes the degenerate-simplex divergence noted when the backend was introduced (curvature losses crashed on collinear input) and 0.3.0 added two APIs that move LearnerND's remaining Python hot loops into Rust. This bumps _MIN_RUST_VERSION to (0, 3, 1) and adopts both: - tell_pending asks the triangulation for all simplices containing the pending point in one simplices_containing call (with the known containing simplex as a hint) instead of looping point_in_simplex over every neighbouring simplex; the pure-Python backend keeps the original loop. - LearnerND's default loss_per_simplex is the Rust default_loss when the Rust backend is active (same embedded-simplex-volume computation). Together: 1.10x (2D ring_of_fire, 3000 pts) to 1.42x (3D, 1500 pts) faster end-to-end on top of the existing Rust backend, sampling identical points (asserted by a new test). Also adds the Rust-backend CI job deferred when the backend landed: a nox session running the suite with ADAPTIVE_TRIANGULATION_BACKEND=rust, now that the full suite passes with it (294 passed; previously 7 known curvature-loss failures).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #493, completing the two items it deferred. adaptive-triangulation 0.3.1 fixes the known degenerate-simplex divergence (curvature losses crashed on collinear input with the Rust backend), and 0.3.0 added two batched APIs targeting
LearnerND's remaining Python hot loops. This PR bumps_MIN_RUST_VERSIONto(0, 3, 1), adopts both APIs, and adds the deferred Rust-backend CI job.Changes
tell_pending: distributing a pending point over the simplices that contain it previously loopedtri.point_in_simplexover every simplex sharing a vertex with the containing simplex (~14 checks per point in 2D, ~70 in 3D, ~96% misses). With the Rust backend this is now onetri.simplices_containing(point, simplex=hint)call (feature-detected viahasattr, so a directly-passed custom triangulation class keeps working). The pure-Python backend keeps the original loop, refactored into_simplices_containing_point+_add_pending_point_to_simplexso both paths share the insertion code.default_loss: when the Rust backend is active,LearnerNDusesadaptive_triangulation.default_lossas the defaultloss_per_simplex— the same embedded-simplex-volume computation without the per-simplex Python tuple-splicing. Exposed astriangulation_backend.rust_default_loss(Noneon the python backend) to avoid a circular import withlearnerND. Pickling adds no new constraint: a learner on the Rust backend already referencesadaptive_triangulationobjects.pytest_rust_backendnox session (installs.[test,other,rust], runs the suite withADAPTIVE_TRIANGULATION_BACKEND=rust) and atest-rust-backendjob innox.yml.rustextra bumped toadaptive-triangulation>=0.3.1;_MIN_RUST_VERSION = (0, 3, 1)(0.2.x installs now fall back to the python backend rather than using a version without the degenerate-simplex fix).Performance
End-to-end
LearnerNDvs adaptive 1.5.0, both with the Rust backend (best of 3):ring_of_fire, 3000 ptssphere_of_fire, 1500 ptsThe gain grows with dimension (vertex stars get bigger). Sampled points are identical between the python and rust backends — asserted by a new test that runs both for 200 points.
Testing
test_rust_default_loss_matches_backend(both env configurations) andtest_rust_backend_samples_identical_points.